home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / animwr1.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  4KB  |  157 lines

  1. /*
  2.    This is the opening phase of the ARexx scripts for making ANIM's
  3.    
  4.    This script gets three things from the user and sticks them into a
  5.    file in ram: so the other three phases of the process will know what
  6.    to do.
  7.    
  8.      1 - The name of the ANIM to create or extend is obtained
  9.      2 - The name template to be used for the individual frames is obtained.
  10.      3 - The number of jiffies between frames.
  11.  */
  12. call pragma('stack',20000);
  13.  
  14. /*
  15.  * open rexxsupport.library -- needed for some functions
  16.  */
  17. if ~show('L',"rexxsupport.library") then do
  18.   if addlib('rexxsupport.library',0,-30,0) then do
  19.       /* everything's ok */
  20.     end;
  21.   else do
  22.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  23.     say 'Cannot operate animr.rexx without this library - sorry!';
  24.     exit 10;
  25.     end;
  26.   end;
  27.  
  28. /*
  29.  * This will automatically direct the script to the proper
  30.  * software, if it is running.
  31.  */
  32. prtnme = 'IP_Port'; /* assume Image Professional */
  33. if show('P','IP_Port') = 0 then do
  34.   if show('P','IM_Port') = 0 then do
  35.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  36.     say "This script requires IP, IM or IM F/c to run!";
  37.     exit(20);
  38.     end;
  39.   else do
  40.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  41.     end;                 /* We make em, user's break em.          */
  42.   end;
  43.  
  44. options;
  45. address;
  46.  
  47.   prevpath = 'ram:'; /* put user in ram to start with... */
  48.  
  49.   if show('C',animpath) = 1 then do
  50.     prevpath = getclip(animpath);
  51.     end;
  52.  
  53.   address(prtnme);
  54.  
  55.   options results;
  56.   'filerequest "'||prevpath||'","'||bufname||'",".anim","Make Anim"';
  57.   animfile = result;
  58.   options;
  59.  
  60.   if animfile = 'FR_CANCELLED' then do
  61.     address(prtnme);
  62.     'imtofront';
  63.     exit 0;
  64.     end;
  65.   else do
  66.     animfile = expandfilename(animfile);
  67.     thispath = gimmepath(animfile);
  68.     call setclip(animpath,thispath);
  69.   end;
  70.  
  71.   options results;
  72.   'askprop '||'"# of jiffies (60th / sec) between frames?" 2 1 180'
  73.   jiffies = result;
  74.   options;
  75.  
  76.   res = open(fhandle,animfile,'read');
  77.   if res ~= 0 then do
  78.     call close(fhandle);
  79.     address(prtnme);
  80.     options results;
  81.     'askyn '||'"Create New ANIM" "Append to Existing ANIM"'
  82.     prefs = result;
  83.     if prefs = 0 then do
  84.       address command 'c:delete >nil: '||animfile;
  85.       end;
  86.     if prefs = 1 then do
  87.       options results;
  88.       'askyn '||'"Truncate before appending" "Append as is"'
  89.       prefs = result;
  90.       if prefs = 0 then do
  91.         address command 'cmpi:ANIMWR -t '||jiffies||' '||animfile;
  92.         end;
  93.       end;
  94.     end;
  95.  
  96.   call open(fhandle,'ram:IP_ANIMWR.CFG','write');      /* open the file */
  97.   junk = writeln(fhandle, jiffies);
  98.   junk = writeln(fhandle, animfile);
  99.   call close(fhandle);                     /* close the file    */
  100.  
  101.   address(prtnme);
  102.   'finish';
  103.   exit 0;
  104.  
  105.  
  106. /*
  107.  * gimmepath
  108.  *
  109.  * This takes the provided argument and sucks the path out of it, then
  110.  * returns that path to the caller, sans file name.
  111.  */
  112. gimmepath:
  113.   arg fullnamegx;
  114.     tempgx = reverse(fullnamegx);
  115.     lengx = length(fullnamegx);   /* get length of string */
  116.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  117.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  118.     seploc = 0; /* assumes current dir, no path supplied */
  119.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  120.       seploc = (lengx - slashdex)+1;
  121.       end;
  122.     else do
  123.       if colondex ~= 0 then do /* we assume we are on a device */
  124.         seploc = (lengx - colondex)+1;
  125.         end;
  126.       end;
  127.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  128.   gxpath = left(fullnamegx,seploc);
  129.   return(gxpath);
  130.  
  131. /*
  132.  * Since this script can't be expected to know where the CD of the user
  133.  * is when this cmd is invoked, we have to check the path the user
  134.  * provides - if it's not specified right from a root, then we have
  135.  * to make it a complete specification from the root.
  136.  */
  137. expandfilename:
  138.   parse arg jfile;
  139.   if index(jfile,':') = 0 then do
  140.     curdir = pragma(D);
  141.     if right(curdir,1) ~= ':' then do
  142.       if right(curdir,1) ~= '/' then do
  143.         if curdir ~= '' then do
  144.           curdir = curdir || '/';
  145.           end;
  146.         end;
  147.       end;
  148.     jfile = curdir||jfile;
  149.     end;
  150.   return(jfile);
  151.  
  152. rvalue:
  153.   wordnum = c2d(readch(fhandle,1)) * 256;
  154.   wordnum = wordnum + c2d(readch(fhandle,1));
  155.   return wordnum;
  156.  
  157.